<?php  
    include_once ('lib_game/briggsoft/api.php');
    function games_api($game_brand_param,$params,$assoc)
    {
        $ci=& get_instance();
        //$active_code = $ci->config->item('active_code');
        $active_code = $game_brand_param;
        
        $config = $ci->config->item($active_code);
        
        $url = $config["api_url"]; // set your url here
        $pw = $config["api_pass"];
        $server = $config['server_url'];
        if ($active_code == 'briggsoft')
        {
            $params = "Password=$pw&".$params;
            $api = Poker_API($url,$params,$assoc);
            if (isset($api['SessionKey']))
                $api['urlRedirct'] = $server . "/?LoginName=" . $api['Player'] . "&SessionKey=" . $api['SessionKey'];
            return $api;
        } 
        else
            return null;
    }
    
    function games_api_login($game_brand_param, $params)
    {
        $active_code = $game_brand_param;
        if ($active_code == 'briggsoft')
        {
            $params = "Command=AccountsPassword&" . $params;
            return games_api($game_brand_param, $params, true);
        } 
        else
            return null;
    }
    
    function games_api_play($game_brand_param, $params)
    {
        $active_code = $game_brand_param;
        if ($active_code == 'briggsoft')
        {
            $params = "Command=AccountsSessionKey&" . $params;
            return games_api($game_brand_param, $params, true);
        } 
        else
            return null;
    }
    function games_api_newPlayer($game_brand_param, $params)
    {
        $active_code = $game_brand_param;
        if ($active_code == 'briggsoft')
        {
            $params = "Command=AccountsAdd&" . $params;
            return games_api($game_brand_param, $params, true);
        } 
        else
            return null;
    }
    function games_api_putCoins($game_brand_param, $params)
    {
        $active_code = $game_brand_param;
        if ($active_code == 'briggsoft')
        {
            $params = "Command=AccountsIncBalance&" . $params;
            return games_api($game_brand_param, $params, true);
        } 
        else
            return null;
    }
    function games_api_getPlayerInfo($game_brand_param, $params){
        $active_code = $game_brand_param;
        if ($active_code == 'briggsoft')
        {
            $params = "Command=AccountsGet&" . $params;
            return games_api($game_brand_param, $params, true);
        } 
        else
            return null;
    }
    function games_api_exceptCoins($game_brand_param, $params)
    {
        $active_code = $game_brand_param;
        if ($active_code == 'briggsoft')
        {
             //http://game4fun.test:8087/api?Password=123456&Command=AccountsDecBalance&Player=huy0&Amount=100&Negative=allow
            $params = "Command=AccountsDecBalance&" . $params;
            return games_api($game_brand_param, $params, true);
        }
        else
            return null;
    }

    //function games_api($url,$params,$assoc)
//    {
//        $ci=& get_instance();
//        $active_code = $ci->config->item('active_code');
//        $h_config = $ci->config->item($active_code);
//        
//        if ($active_code == 'briggsoft') 
//            return Poker_API($url,$params,$assoc);
//        else
//            return null;
//    }
?>